package inglar.autotc.client;

import inglar.autotc.shared.db.Actions;
import inglar.autotc.shared.db.Templates;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

/**
 * Wraps the command line utilities of the Linux-based host system.
 * @author Lee
 */
@RemoteServiceRelativePath("HostService")
public interface HostService extends RemoteService {
	/**
	 * Utility class for simplifying access to the instance of async service.
	 */
	public static class Util {
		private static HostServiceAsync instance;
		public static HostServiceAsync getInstance(){
			if (instance == null) {
				instance = GWT.create(HostService.class);
			}
			return instance;
		}
	}
	
	String exec(String cmd);
	String scriptase(String cmd);
	
	String checkInstallation();
	
	String login(String username, String password);
	
	String[] getDeviceList(String userid);
	
	String[] getDeviceConfig(String userid, String device);
	String setDeviceConfig(String userid, String device, String settingid, String script);
	
	Templates[] getTemplateList(String userid);
	String[] getTemplateList(String userid, String device);
	String setTemplate(String userid, String device, String name, String script);
	
	String[] getClientList(String userid);
	String setClient(String userid, String ipaddr, Integer port);
	String deleteClient(String userid, String ipaddr, Integer port);
	
	String[] netstat(String userid, String ipaddress, Integer port);
	
	String[] getActionList(String userid);
	void setAction(String userid, Actions action);
	String deleteAction(String userid, String actionid);
}
